package net.sapfree.core.util.format;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

public class JavaInputStreamFormat extends ValueObjectFormat
{
	public InputStream getInputStream(Object value)
	{ 
		return (InputStream)value;
	}
	
	
	public Reader getReader(Object value)
	{ 
		return value == null ? null : new InputStreamReader((InputStream)value);
	}
	
	public int getLength(Object value)
	{
		try
		{
			return value == null ? 0 : ((InputStream)value).available();
		} 
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
}
